package com.bwie.controller;

import cn.hutool.core.util.ObjectUtil;
import com.bwie.Result;
import com.bwie.mq.MessageProduce;
import com.bwie.pojo.po.OrderPo;
import com.bwie.pojo.po.OrderTypePo;
import com.bwie.service.OrderService;
import com.bwie.utils.poi.EasyPoiUtil;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @className: OrderController
 * @Description: TODO
 * @version: v1.８.0
 * @author: 杜林涛
 * @date: 2025/6/11 10:39
 */
@Controller
@RequestMapping("order")
public class OrderController {
    @Autowired
    OrderService orderService;
    EasyPoiUtil easyPoiUtil;

    //订单列表页面
    @RequestMapping("list")
    public String list() {
        return "/order/list";
    }

    //订单列表
    @RequestMapping("oList")
    @ResponseBody
    public PageInfo<OrderPo> oList(OrderPo orderPo) {
        return orderService.oList(orderPo);
    }

    /**
     * 导出
     *
     * @param response
     */
    @RequestMapping("leadingOut")
    public void leadingOut(HttpServletResponse response) {
        List<OrderPo> list = orderService.selectStuAll();
        if (ObjectUtil.isNull(list)) {
            return;
        }
        easyPoiUtil.exportExcel(response, list, OrderPo.class, "订单详情");
    }

    /**
     * 订单下拉框
     */
    @RequestMapping("cc")
    @ResponseBody
    public List<OrderTypePo> cc() {
        return orderService.cc();
    }

    /**
     * 新增
     */
    @RequestMapping("add")
    public String add() {
        return "/order/add";
    }

    @RequestMapping("oAdd")
    @ResponseBody
    public Result oAdd(OrderPo orderPo) {
        return orderService.oAdd(orderPo);
    }

    /**
     * 图表
     */
    @RequestMapping("tu")
    public String tu() {
        return "/order/tu";
    }

    @RequestMapping("zhu")
    @ResponseBody
    public Result<List<Map<String, Object>>> count() {
        return orderService.count();
    }

    /**
     * 批删
     */
    @RequestMapping("oDel")
    @ResponseBody
    public Result oDel(@RequestBody List<Integer> dek){
        return orderService.oDel(dek);
    }
}